package com.yztl.util;

import java.util.List;

/**
 * 分页工具类
 */
public class PageUtil<T> {
    // 五个属性
    /**
     * 当前页(页码)
     */
    private int pageIndex = 1;
    /**
     * 页面大小
     */
    private int pageSize = 10;
    /**
     * 记录总数
     */
    private int counts = 0;
    /**
     * 总页数
     */
    private int pageCount = 0;
    /**
     * 保存当前页面对象集合
     */
    private List<T> lists;

    public int getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getCounts() {
        return counts;
    }

    public void setCounts(int counts) {
        this.counts = counts;
        if (counts > 0) {
            //判断是否整除
            pageCount = counts % pageSize == 0 ? (counts / pageSize) : ((counts / pageSize) + 1);
        }
    }

    public int getPageCount() {
        return pageCount;
    }

    public void setPageCount(int pageCount) {
        this.pageCount = pageCount;
    }

    public List<T> getLists() {
        return lists;
    }

    public void setLists(List<T> lists) {
        this.lists = lists;
    }

}
